﻿using System;
using System.Architecture;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows.Input;
using HDK.UI.Controls;
using Microsoft.Practices.Prism.Regions;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

namespace HDK.Demo
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class Shell : LayoutAwarePage
    {
        IRegionManager regionManager;
        public Shell(IRegionManager regionManager)
        {
            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled) return;

            this.InitializeComponent();
            this.DataContext = new ShellViewModel();

            this.Loaded += Shell_Loaded;
            //this.Unloaded += Shell_Unloaded;


            this.regionManager = regionManager;
            RegionManager.SetRegionManager(this.shellFrame, regionManager);
            RegionManager.SetRegionName(this.shellFrame, "MainRegion");
        }

        void Shell_Unloaded(object sender, RoutedEventArgs e)
        {
            //this.StopLayoutUpdates(sender, e);
            //Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated -= CoreDispatcher_AcceleratorKeyActivated;
            //Window.Current.CoreWindow.PointerPressed -= this.CoreWindow_PointerPressed;
        }

        void Shell_Loaded(object sender, RoutedEventArgs e)
        {

            //regionManager.AddToRegion("MainRegion", new Button() { Content = "shalom", Width = 100, Height = 100 });
            breadcrumb.ItemsSource = RegionManager.GetRegionNavigationJournal(shellFrame).BackStack;

            regionManager.RequestNavigate("MainRegion", "//Pages/HelloWorld?Content=Just Test");
            regionManager.RequestNavigate("MainRegion", "//Pages/HelloWorld?Content=AnotherSimpleTest");
            regionManager.RequestNavigate("MainRegion", "//ParallaxView");
            regionManager.RequestNavigate("MainRegion", "//Pages/HDKHUB");
            regionManager.RequestNavigate("MainRegion", "//Pages/GIT");
            regionManager.RequestNavigate("MainRegion", "//Pages/DataVirtualizationTest");
        }

        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }
    }

}
